﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="OAclient.Common" %>

<script type="text/javascript">
    $(function() {
        $(".datepicker").datepicker();
        tableSelectOrder("#msgdrftlist .table_style");
    })
</script>

<script type="text/javascript">
    $(function() {
        var msgdraftlistoptions = {
            url: "/Message/MsgDrftList",
            type: "POST",
            data: { "page": 1 },
            success: function(data) {
                $("#workarea-msg-1").html(data);
            }
        };

        $("#frmmsgdraftlist").ajaxForm(msgdraftlistoptions);
    })

    // 查看草稿箱
    function msgdraftshow(msg_id) {
        $.ajax({
            type: "POST",
            url: "/Message/MsgSend",
            data: { "msg_id": msg_id },
            success: function(data) {
                addtab('msg-1', '发送信息');
                $("#workarea-msg-1").html(data);
            }
        })
    }
</script>

<div id="msgdrftlist" style="padding-top: 35px;">
    <%using (Html.BeginForm("MsgDrftList", "Message", new { page = 1 }, FormMethod.Post, new { id = "frmmsgdraftlist" }))
      { %>
    <div class="selectpanel" style="margin: 5px 20px 5px 70px;">
        标题:
        <%=Html.TextBox("searchtitle_msgdrftlist")%>
        内容:
        <%=Html.TextBox("searchcontent_msgdrftlist")%>
        接收时间:
        <%=Html.TextBox("searchstime_msgdrftlist", "", new { @class = "datepicker" })%>
        -
        <%=Html.TextBox("searchetime_msgdrftlist", "", new { @class = "datepicker" })%>
        <input class="btn_style" type="submit" value="查询" name="submit" />
    </div>
    <table border="0" width="100%" class="table_style" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <th>
                    标题
                </th>
                <th>
                    接收人
                </th>
                <th>
                    发送时间
                </th>
                <th>
                    消息状态
                </th>
                <th>
                </th>
            </tr>
        </thead>
        <tbody>
            <%
                System.Data.DataTable dt = ViewData["dt"] as System.Data.DataTable;
                if (dt == null || dt.Rows.Count == 0)
                {%>
            <tr>
                <td colspan="0" style="text-align: center;">
                    当前无数据！
                </td>
            </tr>
            <%}
                else
                {
                    int count = dt.Rows.Count;
                    for (int i = 0; i < count; i++)
                    {
            %>
            <tr>
                <td>
                    <%=dt.Rows[i]["标题"]%>
                </td>
                <td>
                    <%=dt.Rows[i]["接收人"]%>
                </td>
                <td>
                    <%=dt.Rows[i]["发送时间"]%>
                </td>
                <td>
                    未发送
                </td>
                <td>
                    <a class="btn_detail" onclick="msgdraftshow(<%=dt.Rows[i]["编码"] %>)">查看</a>
                </td>
            </tr>
            <%
                }
                }%>
        </tbody>
    </table>
    <div id="pageLink">
        <%var pageInfo = ViewData["pageInfo"] as PagingInfo;%>
        <%if (pageInfo != null)
          { %>
        <%=Ajax.PageLinks(pageInfo, index => Url.Action("MsgDrftList", new { page = index }), new AjaxOptions { UpdateTargetId = "workarea-msg-3" })%>
        <%} %>
    </div>
    <%} %>
</div>
